{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "724a0501",
   "metadata": {},
   "outputs": [],
   "source": [
    "usernames = \"10\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "dee11ef2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'10'"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "usernames"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "39bbd1fc",
   "metadata": {},
   "outputs": [],
   "source": [
    "usernames = input(\"请输入你的账户余额：\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2b3a1a64",
   "metadata": {},
   "outputs": [],
   "source": [
    "squares = [\n",
    "    \"辣条1r\",\n",
    "    \"润唇膏50r\",\n",
    "    \"麻薯20r\",\n",
    "    \"口红300r\",\n",
    "    \"外套450r\"]\n",
    "print(squares)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5835783f",
   "metadata": {},
   "outputs": [],
   "source": [
    "username_database_list = [\n",
    "    \"辣条1r\",\n",
    "    \"润唇膏50r\",\n",
    "    \"麻薯20r\",\n",
    "    \"口红300r\",\n",
    "    \"外套450r\"]\n",
    "usernames = input(\"请输入你的账户余额：\")\n",
    "if usernames_data ==price:\n",
    "    print(username_database_list[1])\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ec028119",
   "metadata": {},
   "outputs": [],
   "source": [
    "goods_list = [\n",
    "    ['香奈儿炫光84',350],\n",
    "    ['香奈儿838',350],\n",
    "    ['润唇膏',50],\n",
    "    ['armani214',310],\n",
    "    ['cheerflor1122肉桂奶咖',39]\n",
    "]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9ab7638f",
   "metadata": {},
   "outputs": [],
   "source": [
    "goods_list[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 112,
   "id": "176f31ba",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "--------------------商品信息-------------------\n",
      "商品编号: 0 ,商品名称: 香奈儿炫光84 ,商品价格: 350\n",
      "商品编号: 1 ,商品名称: 香奈儿838 ,商品价格: 350\n",
      "商品编号: 2 ,商品名称: 润唇膏 ,商品价格: 50\n",
      "商品编号: 3 ,商品名称: armani214 ,商品价格: 310\n",
      "商品编号: 4 ,商品名称: cheerflor1122肉桂奶咖 ,商品价格: 39\n"
     ]
    }
   ],
   "source": [
    "goods_list = [\n",
    "    ['香奈儿炫光84',350],\n",
    "    ['香奈儿838',350],\n",
    "    ['润唇膏',50],\n",
    "    ['armani214',310],\n",
    "    ['cheerflor1122肉桂奶咖',39]\n",
    "]\n",
    "print('--------------------商品信息-------------------')\n",
    "print(\"商品编号:\",0,\",商品名称:\",goods_list[0][0],\",商品价格:\",goods_list[0][1])\n",
    "print(\"商品编号:\",1,\",商品名称:\",goods_list[1][0],\",商品价格:\",goods_list[1][1])\n",
    "print(\"商品编号:\",2,\",商品名称:\",goods_list[2][0],\",商品价格:\",goods_list[2][1])\n",
    "print(\"商品编号:\",3,\",商品名称:\",goods_list[3][0],\",商品价格:\",goods_list[3][1])\n",
    "print(\"商品编号:\",4,\",商品名称:\",goods_list[4][0],\",商品价格:\",goods_list[4][1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 115,
   "id": "960c82e5",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "--------------------商品信息-------------------\n",
      "商品编号: 0 ,商品名称: 香奈儿炫光84 ,商品价格: 350\n",
      "商品编号: 1 ,商品名称: 香奈儿838 ,商品价格: 350\n",
      "商品编号: 2 ,商品名称: 润唇膏 ,商品价格: 50\n",
      "商品编号: 3 ,商品名称: armani214 ,商品价格: 310\n",
      "商品编号: 4 ,商品名称: cheerflor1122肉桂奶咖 ,商品价格: 39\n"
     ]
    }
   ],
   "source": [
    "goods_list = [\n",
    "    ['香奈儿炫光84',350],\n",
    "    ['香奈儿838',350],\n",
    "    ['润唇膏',50],\n",
    "    ['armani214',310],\n",
    "    ['cheerflor1122肉桂奶咖',39]\n",
    "]\n",
    "print('--------------------商品信息-------------------')\n",
    "print(\"商品编号:\",0,\",商品名称:\",goods_list[0][0],\",商品价格:\",goods_list[0][1])\n",
    "print(\"商品编号:\",1,\",商品名称:\",goods_list[1][0],\",商品价格:\",goods_list[1][1])\n",
    "print(\"商品编号:\",2,\",商品名称:\",goods_list[2][0],\",商品价格:\",goods_list[2][1])\n",
    "print(\"商品编号:\",3,\",商品名称:\",goods_list[3][0],\",商品价格:\",goods_list[3][1])\n",
    "print(\"商品编号:\",4,\",商品名称:\",goods_list[4][0],\",商品价格:\",goods_list[4][1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 148,
   "id": "59ca9e7d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "--------------------商品信息-------------------\n",
      "商品编号:0,商品名称:香奈儿炫光84,商品价格:350\n",
      "商品编号:1,商品名称:香奈儿838,商品价格:350\n",
      "商品编号:2,商品名称:润唇膏,商品价格:50\n",
      "商品编号:3,商品名称:armani214,商品价格:310\n",
      "商品编号:4,商品名称:cheerflor1122肉桂奶咖,商品价格:39\n",
      "--------------------------------------------------------------------------\n",
      "商品编号:0,商品名称:香奈儿炫光84,商品价格:350\n",
      "商品编号:1,商品名称:香奈儿838,商品价格:350\n",
      "商品编号:2,商品名称:润唇膏,商品价格:50\n",
      "商品编号:3,商品名称:armani214,商品价格:310\n",
      "商品编号:4,商品名称:cheerflor1122肉桂奶咖,商品价格:39\n"
     ]
    }
   ],
   "source": [
    "goods_list = [\n",
    "    ['香奈儿炫光84',350],\n",
    "    ['香奈儿838',350],\n",
    "    ['润唇膏',50],\n",
    "    ['armani214',310],\n",
    "    ['cheerflor1122肉桂奶咖',39]\n",
    "]\n",
    "print('--------------------商品信息-------------------')\n",
    "print(\"商品编号:%s,商品名称:%s,商品价格:%s\"%(0,goods_list[0][0],goods_list[0][1]))\n",
    "print(\"商品编号:%s,商品名称:%s,商品价格:%s\"%(1,goods_list[1][0],goods_list[1][1]))\n",
    "print(\"商品编号:%s,商品名称:%s,商品价格:%s\"%(2,goods_list[2][0],goods_list[2][1]))\n",
    "print(\"商品编号:%s,商品名称:%s,商品价格:%s\"%(3,goods_list[3][0],goods_list[3][1]))\n",
    "print(\"商品编号:%s,商品名称:%s,商品价格:%s\"%(4,goods_list[4][0],goods_list[4][1]))\n",
    "print(\"--------------------------------------------------------------------------\")\n",
    "for i in range(5):\n",
    "    print(\"商品编号:%s,商品名称:%s,商品价格:%s\"%(i,goods_list[i][0],goods_list[i][1]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 163,
   "id": "f0ca5d1a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入你的账户余额:100\n",
      "--------------------商品信息-------------------\n",
      "商品编号:0,商品名称:香奈儿炫光84,商品价格:350\n",
      "商品编号:1,商品名称:香奈儿838,商品价格:350\n",
      "商品编号:2,商品名称:润唇膏,商品价格:50\n",
      "商品编号:3,商品名称:armani214,商品价格:310\n",
      "商品编号:4,商品名称:cheerflor1122肉桂奶咖,商品价格:39\n",
      "请输入商品编号：2\n",
      "已经将【润唇膏】加到你的购物车，余额还剩【50】\n"
     ]
    }
   ],
   "source": [
    "### 1. 商品列表\n",
    "goods_list = [\n",
    "    ['香奈儿炫光84',350],\n",
    "    ['香奈儿838',350],\n",
    "    ['润唇膏',50],\n",
    "    ['armani214',310],\n",
    "    ['cheerflor1122肉桂奶咖',39]\n",
    "]\n",
    "### 2. 用户输入\n",
    "Alipay = int(input('请输入你的账户余额:'))\n",
    "# 3. 打印结果 :  商品编号：xxx , 商品的名称:xxx，商品价格: xxx\n",
    "\n",
    "# goods_list[0][0] 商品名称 goods_list[0][1] 商品价格\n",
    "# 占位符 %s s-->str\n",
    "\n",
    "#print('--------------------商品信息-------------------')\n",
    "#print(\"商品编号:%s,商品名称:%s,商品价格:%s\"%(0,goods_list[0][0],goods_list[0][1]))\n",
    "#print(\"商品编号:%s,商品名称:%s,商品价格:%s\"%(1,goods_list[1][0],goods_list[1][1]))\n",
    "#print(\"商品编号:%s,商品名称:%s,商品价格:%s\"%(2,goods_list[2][0],goods_list[2][1]))\n",
    "#print(\"商品编号:%s,商品名称:%s,商品价格:%s\"%(3,goods_list[3][0],goods_list[3][1]))\n",
    "#print(\"商品编号:%s,商品名称:%s,商品价格:%s\"%(4,goods_list[4][0],goods_list[4][1]))\n",
    "print('--------------------商品信息-------------------')\n",
    "for i in range(len(goods_list)):\n",
    "    print(\"商品编号:%s,商品名称:%s,商品价格:%s\"%(i,goods_list[i][0],goods_list[i][1]))\n",
    "    \n",
    "choice = input('请输入商品编号：')\n",
    "if Alipay >= goods_list[int(choice)][1]:\n",
    "    Alipay = Alipay - goods_list[int(choice)][1] #扣钱\n",
    "    print(\"已经将【%s】加到你的购物车，余额还剩【%s】\"%(goods_list[int(choice)][0],Alipay))\n",
    "else:\n",
    "    print(\"您的余额不足，剁手吧。\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "df8cfe82",
   "metadata": {},
   "outputs": [],
   "source": [
    "while True:\n",
    "if choice.sidigit():\n",
    "    eise:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 162,
   "id": "a84bba15",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入你的账户余额:100\n",
      "--------------------商品信息-------------------\n",
      "商品编号:0,商品名称:香奈儿炫光84,商品价格:350\n",
      "商品编号:1,商品名称:香奈儿838,商品价格:350\n",
      "商品编号:2,商品名称:润唇膏,商品价格:50\n",
      "商品编号:3,商品名称:armani214,商品价格:310\n",
      "商品编号:4,商品名称:cheerflor1122肉桂奶咖,商品价格:39\n",
      "请输入商品编号：1\n",
      "您的余额不足，剁手吧。\n"
     ]
    }
   ],
   "source": [
    "goods_list = [\n",
    "    ['香奈儿炫光84',350],\n",
    "    ['香奈儿838',350],\n",
    "    ['润唇膏',50],\n",
    "    ['armani214',310],\n",
    "    ['cheerflor1122肉桂奶咖',39]\n",
    "]\n",
    "Alipay = int(input('请输入你的账户余额:'))\n",
    "print('--------------------商品信息-------------------')\n",
    "while True:\n",
    "    for i in range(len(goods_list)):\n",
    "        print(\"商品编号:%s,商品名称:%s,商品价格:%s\"%(i,goods_list[i][0],goods_list[i][1]))\n",
    "        choice = input('请输入商品编号（输入‘q’退出购买）:')\n",
    "        # input()默认是 str\n",
    "         # 4. 让用户输入商品编号进行商品的购买\n",
    "        if choice.isdigit():\n",
    "          \n",
    "            # 一、用户输入的是编号\n",
    "        # ①. 编号在列表范围内\n",
    "        \n",
    "    \n",
    "\n",
    "if Alipay >= goods_list[int(choice)][1]:\n",
    "    Alipay = Alipay - goods_list[int(choice)][1] #扣钱\n",
    "    print(\"已经将【%s】加到你的购物车，余额还剩【%s】\"%(goods_list[int(choice)][0],Alipay))\n",
    "else:\n",
    "    print(\"您的余额不足，剁手吧。\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a38fdb37",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "76c819e3",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
